<?php
namespace Hr\OnlineBundle\Entity;


use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

use Hr\OnlineBundle\Lib\Globals;

/**
 * @ORM\Entity(repositoryClass="Hr\OnlineBundle\Entity\Repository\TokenRepository")
 * @ORM\Table(name="token")
 * @ORM\HasLifecycleCallbacks()
 */
class Token
{
	/**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="string", length=255)
     */
    protected $hash;

    /**
     * @ORM\Column(name="is_used", type="boolean")
     */
    protected $isUsed;


    /**
     * @ORM\Column(name="created_at", type="datetime")
     */
    protected $createdAt;



    /**
     * @ORM\Column(name="expires_at", type="datetime")
     */
    protected $expiresAt;


    /**
     * @ORM\Column(name="used_at", type="datetime")
     */
    protected $usedAt;


    /**
     * @ORM\ManyToOne(targetEntity="User", inversedBy="tokens")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
     */
    protected $user;


    public function __construct()
    {

        $this->setCreatedAt(new \DateTime());
        $this->setUsedAt(new \DateTime());

        $this->setIsUsed(false);
		

    }



    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set hash
     *
     * @param string $hash
     * @return Token
     */
    public function setHash($hash)
    {
        $this->hash = $hash;
    
        return $this;
    }

    /**
     * Get hash
     *
     * @return string 
     */
    public function getHash()
    {
        return $this->hash;
    }

    /**
     * Set isUsed
     *
     * @param boolean $isUsed
     * @return Token
     */
    public function setIsUsed($isUsed)
    {
        $this->isUsed = $isUsed;
    
        return $this;
    }

    /**
     * Get isUsed
     *
     * @return boolean 
     */
    public function getIsUsed()
    {
        return $this->isUsed;
    }

    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     * @return Token
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;
    
        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime 
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * Set expiresAt
     *
     * @param \DateTime $expiresAt
     * @return Token
     */
    public function setExpiresAt($expiresAt)
    {
        $this->expiresAt = $expiresAt;
    
        return $this;
    }

    /**
     * Get expiresAt
     *
     * @return \DateTime 
     */
    public function getExpiresAt()
    {
        return $this->expiresAt;
    }

    /**
     * Set usedAt
     *
     * @param \DateTime $usedAt
     * @return Token
     */
    public function setUsedAt($usedAt)
    {
        $this->usedAt = $usedAt;
    
        return $this;
    }

    /**
     * Get usedAt
     *
     * @return \DateTime 
     */
    public function getUsedAt()
    {
        return $this->usedAt;
    }

    /**
     * Set user
     *
     * @param \Hr\OnlineBundle\Entity\User $user
     * @return Token
     */
    public function setUser(\Hr\OnlineBundle\Entity\User $user = null)
    {
        $this->user = $user;
    
        return $this;
    }

    /**
     * Get user
     *
     * @return \Hr\OnlineBundle\Entity\User 
     */
    public function getUser()
    {
        return $this->user;
    }
}